package cn.wolfcode.wms.service.impl;

import cn.wolfcode.wms.domain.ProductStock;
import cn.wolfcode.wms.mapper.ProductStockMapper;
import cn.wolfcode.wms.qo.QueryObject;
import cn.wolfcode.wms.service.IProductStockService;
import cn.wolfcode.wms.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductStockImpl implements IProductStockService {
    @Autowired
    private ProductStockMapper productStockMapper;



    @Override
    public ProductStock get(Long id) {

            ProductStock entity = productStockMapper.selectByPrimaryKey(id);
        return entity;

    }

    @Override
    public List<ProductStock> selectall() {
        List<ProductStock> depts = productStockMapper.selectAll();
        return depts;
    }

    @Override
    public PageResult queryForList(QueryObject qo) {
        int rows = productStockMapper.rows(qo);
        if (rows == 0) {
            return PageResult.EMPTY_RESULT;
        }
        PageResult result = new PageResult(qo.getCurrentPage(), qo.getPageSize(), rows, productStockMapper.queryForList(qo));

        return result;

    }
}
